//
//  CommentModelDataSourceProtocolTests.swift
//  travelMapMvvm-swift2
//
//  Created by green on 15/11/4.
//  Copyright © 2015年 travelMapMvvm-swift2. All rights reserved.
//

import Foundation
import XCTest
import ReactiveCocoa
import TMDatasourceLib
import TMCommonLib

class CommentModelDataSourceProtocolTests: XCTestCase {

    var commentModelDataSourceProtocol: CommentModelDataSourceProtocol!
    
    override func setUp() {
        super.setUp()
        
        commentModelDataSourceProtocol = CommentModelDataSource.shareInstance()
    }
    
    override func tearDown() {
        super.tearDown()
    }
    
    /**
     查询目的地评论列表
     */
    func testQueryPOICommentList(){
        
        let expectation = expectationWithDescription(kURL+"getPOIComments")
        
        commentModelDataSourceProtocol.queryPOICommentList(1, pageSize: 10, poiId: "472622130",poiType:1).subscribeNext({ (any:AnyObject!) -> Void in
            
            expectation.fulfill()
            XCTAssert(any is [CommentModel],"response obj is not [CityModel]")
            
            print(any as! [CommentModel])
            
        }, error: { (error:NSError!) -> Void in
            
            expectation.fulfill()
            XCTFail(error.localizedDescription)
            
        })
        
        waitForExpectationsWithTimeout(10, handler: {error in
        })
    }
    
    /**
     新增评论
     */
    func testAddPOIComment(){
        
        let expectation = expectationWithDescription(kURL+"savePoiComment")
        
        commentModelDataSourceProtocol.addPOIComment("472622130", content: "testcontent2", level: 1, userId: 1,poiType: 1).subscribeNext({ (any:AnyObject!) -> Void in
            
            expectation.fulfill()
            XCTAssert(any is String,"response obj is not String")
            
            print(any as? String)
            
        }, error: { (error:NSError!) -> Void in
            
            expectation.fulfill()
            XCTFail(error.localizedDescription)
            
        })
        
        waitForExpectationsWithTimeout(10, handler: {error in
        })
    }
}
